package com.flowplan.entity.enums;

/**
 * 用户角色枚举
 * 
 * @author FlowPlan Team
 */
public enum UserRole {
    /**
     * 系统管理员
     */
    ADMIN("ADMIN", "系统管理员"),
    
    /**
     * 开发人员
     */
    DEVELOPER("DEVELOPER", "开发人员"),
    
    /**
     * 需求方
     */
    DEMANDER("DEMANDER", "需求方"),
    
    /**
     * 测试人员
     */
    TESTER("TESTER", "测试人员"),
    
    /**
     * 数据库管理员
     */
    DBA("DBA", "数据库管理员");
    
    private final String code;
    private final String description;
    
    UserRole(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static UserRole fromCode(String code) {
        for (UserRole role : values()) {
            if (role.code.equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Invalid user role code: " + code);
    }
}